﻿Public Class ViewCheckIn

    Private Sub ViewCheckIn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        UI.SetPlaceHolder(txtsearch)
        UI.FormatDataGrid(DataGridView1)
        loadCheckin()
    End Sub

    Private Sub loadCheckin()
        Dim sql = <sql>
                    SELECT c.CheckInId,C.ClientId,cl.ClientName,rt.ReservationType,c.ReservationTypeId,c.CheckInDate,c.DateIn,c.DateOut,c.TotalRoom 
                    FROM CheckIn c
                    INNER JOIN ReservationType rt on rt.ReservationTypeId=c.ReservationTypeId
                    INNER JOIN Client cl on cl.ClientId=c.ClientId
                    WHERE c.DateOut >= CONVERT (date, GETDATE()) AND c.Active=1
                    AND UPPER(cl.ClientName) LIKE UPPER(@S)  
                </sql>
        cmd.Parameters("@s") = "%" + txtsearch.Text + "%"
        DataGridView1.DataSource = cmd.ExecuteDataTable(sql)
    End Sub

    Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged
        loadCheckin()
    End Sub

    Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
        If DataGridView1.SelectedRows.Count > 0 Then
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub
End Class